<template>
  <div class="home-trip">
    <div class="trip-item" v-for="item in tripsList" :key="item.id" @click="toDetail(item.id)">
      <img :src="item.imgList[0].picUrl" :alt="item.imgList[0].title">
      <p>{{ item.title }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "HomeTrip",
  props: {
    tripsList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  methods: {
    toDetail(id) {
      this.$router.push('/detail?id=' + id)
    }
  }
}
</script>

<style scoped>
  .home-trip {
    display: flex;
    background-color: #fff;
    margin: .2rem 0;
  }
  .home-trip .trip-item {
    position: relative;
    flex: 1;
    font-size: .28rem;
    text-align: center;
  }
  .home-trip .trip-item img {
    width: 100%;
  }
  .home-trip .trip-item p {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: .6rem;
    line-height: .6rem;
    background: rgba(0,0,0,.6);
    font-size: .28rem;
    color: #fff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .trip-item::before, .trip-item::after {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    background-color: #e0e0e0;
  }
  .trip-item:nth-child(1) {
    border-right: 1px solid #e0e0e0;
  }
</style>
